//
//  DAnalysisDateTableViewCell.swift
//  Drop
//
//  Created by hushaohua on 2018/7/23.
//  Copyright © 2018年 init. All rights reserved.
//

import UIKit

class DAnalysisDateTableViewCell: UITableViewCell {

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier);
        self.contentView.addSubview(self.titleLabel);
        self.contentView.addSubview(self.datesLabel);
        self.addSubviewConstraints();
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy var titleLabel:UILabel = {
        var label:UILabel = UILabel(frame: .zero);
        label.font = UIFont.systemFont(ofSize: 16, weight:.thin);
        label.textColor = UIColor.rgbColor(66, 66, 66);
        label.translatesAutoresizingMaskIntoConstraints = false;
        return label;
    }();
    
    lazy var datesLabel:UILabel = {
        var label:UILabel = UILabel(frame: .zero);
        label.font = UIFont.systemFont(ofSize: 15);
        label.textColor = UIColor.h_blue();
        label.textAlignment = .right;
        label.numberOfLines = 0;
        label.translatesAutoresizingMaskIntoConstraints = false;
        return label;
    }();
    
    func addSubviewConstraints() {
        let views = ["title" : self.titleLabel, "dates" : self.datesLabel];
        var constraints = [NSLayoutConstraint]();
        constraints += NSLayoutConstraint.constraints(withVisualFormat: "H:|-15-[title]-10-[dates]-5-|", options: [.directionLeadingToTrailing], metrics: nil, views: views);
        constraints += NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[title(==44)]", options: [.directionLeadingToTrailing], metrics: nil, views: views);
        constraints += NSLayoutConstraint.constraints(withVisualFormat: "V:|-10-[dates(>=24)]-10-|", options: [.directionLeadingToTrailing], metrics: nil, views: views);
        NSLayoutConstraint.activate(constraints);
    }

}
